import { request } from '../../utils/request'
const app = getApp()
Component({
  properties: {
    /**
     * 是否来自tabbar
     */
    fromTabbar: {
      type: Boolean,
      value: false
    },
    userId: {
      type: Number,
      value: null
    },
    needPay: {
      type: Boolean,
      value: true
    }
  },

  data: {
    isShowModal: false,
    selectTrue: true,
    isSuccess: false,
    imgUrl: ''
  },

  methods: {
    clickTest() {},
    //点击确定
    onClickConfirm() {
      request({
        url:
          '/mini/api/findNeighbor/directMessage',
        method: 'POST',
        data: {
          userId: Number(this.properties.userId),
          needPay: this.properties.needPay
        }
      }).then((resdata) => {
        if (resdata.code == 200) {
          this.setData({
            imgUrl: resdata.data,
            isSuccess: true
          })
        } else {
          wx.showToast({
            title: resdata.message
          })
        }
      })
    },
    onClickShowModal() {
      if (app.globalData.showModel) {
        return
      }
      app.globalData.showModel = true
      this.setData({
        isShowModal: true
      })
    },
    onClickHideModal() {
      this.setData({
        isShowModal: false
      })
      app.globalData.showModel = false
    }
  }
})
